import requests
import json
page_url = 'https://m.umu.cn/passport/ajax/account/login'
payload = {"username": 'zmsxre34026@chacuo.net', "passwd": "zmsxre34026"}  # 值以字典的形式传入
response = requests.post(page_url, data=payload)
response.encoding = 'utf-8'
html = response.text
user_cookie = response.cookies  # 获取cookies
user_json = json.loads(html)  # 用户信息
print("正在登录公共用户赵铁柱")
print("用户ID：" + user_json['data']['user_info']['umu_id'])
print("用户名称：" + user_json['data']['user_info']['user_name'])
if user_json['data']['user_info']['umu_id'] == "赵铁柱":
    print("用户登录成功！")
for item in user_cookie:
    item = str(item)
    if item.find("JSESSID") != -1:
        JSESSID = item[item.find("JSESSID") + 8:item.find("for .umu.cn") - 1]
        print("JSESSID="+JSESSID)
    if item.find("umuU") != -1:
        umuU = item[item.find("umuU") + 5:item.find("for .umu.cn") - 1]
        print("umuU="+umuU)